# coding:utf-8
# @Time      :2022/8/1611:46 PM
# @Author    :peiyu
# @FileName  :good_api
# @email     :geektime
# @Blog      :https://gitee.com/liupeiyu001/geektime_litemall.git
from dataclasses import dataclass

from litemall.api.baseinfo import BaseInfo
from litemall.api.session_api import SessionApi
from litemall.framework.http import Request
from litemall.model.goods import Goods
from litemall.model.session import Session


@dataclass
class GoodsApi:

    def __init__(self):
        self.session = SessionApi()
    def detail(self,goods:Goods):
            product = Request()
            product.method = "get"
            product.type = "json"
            product.query = {"id":goods.goodsid}
            product.headers = {"X-Litemall-Token": self.session.refresh_token()}
            product.path = "/wx/goods/detail"
            product.host = BaseInfo.host
            r = product.send()
            return r